﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sharp.Domain.Model;
using Sharp.Infrastructure;

namespace Sharp.Domain.PlatformBoundedContext.ConfigModule
{
    /// <summary>
    /// 快捷登录用的OAuth
    /// </summary>
    public class OAuthConfig : IAggregateRoot, ILogCreatedEntity, ILogModifiEntity
    {
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public Guid Id { get; set; }
        /// <summary>
        /// 接口
        /// </summary>
        public OAuthType Interface { get; set; }
        [Index]
        public string AppId { get; set; }
        public string AppSecret { get; set; }

        /// <summary>
        /// 第三方登录成功后回传的地址
        /// </summary>
        public string ReturnUrl { get; set; }
        /// <summary>
        /// 可用
        /// </summary>
        public bool IsEnable { get; set; }

        public enum OAuthType
        {
            /// <summary>
            /// 未设置
            /// </summary>
            None = 0,
            /// <summary>
            /// QQ
            /// </summary>
            QQ = 1,
            /// <summary>
            /// 微信
            /// </summary>
            Wechat = 2,
            /// <summary>
            /// 微博
            /// </summary>
            Weibo = 3,
            /// <summary>
            /// 百度
            /// </summary>
            Baidu = 4,
            /// <summary>
            /// 本平台的OAuth验证服务器
            /// </summary>
            Platform = 5
        }
        
        public DateTime? CreatedTime { get; set; }
        public int? CreatedUserId { get; set; }
        public DateTime? ModifiTime { get; set; }
        public int? ModifiedUserId { get; set; }
    }
}
